import Vue from 'vue'
import Vuex from 'vuex'
import { cloneDeep } from 'lodash'

import user from './modules/user'
import common from './modules/common'
import blog from './modules/blog'

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    user,
    common,
    blog
  },
  state: {},
  mutations: {
    // state vuex全部状态
    resetStore(state) {
      Object.keys(state).forEach((key) => {
        state[key] = cloneDeep(window.INIT_CONFIG['storeState'][key])
      })
    }
  },
  actions: {},
  strict: process.env.NODE_ENV !== 'production'
})
